package com.gydz.interferencenetworkmanagement;

import com.gydz.interferencenetworkmanagement.common.netty.server.UdpNettyServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Component;

@Component
public class OnStartListener implements ApplicationListener<ContextRefreshedEvent> {
    private static final Logger log = LoggerFactory.getLogger(User.class);
    private static UdpNettyServer udpNettyServer = new UdpNettyServer();
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
//        log.info("Run on Start Listener.");
//        run();
    }

    private static void run() {
        Thread thread = new Thread(new Runnable() {
            public void run() {
                OnStartListener.udpNettyServer.run(9000);
            }
        });
        thread.start();
    }

    public static void main(String[] args) {
        run();
    }
}
